package com.cqie.tes.config;


import com.cqie.tes.utils.EncryptUtil;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * 自定义的密码加密方法，实现了PasswordEncoder接口
 */
@Component
public class MyPasswordEncoder implements PasswordEncoder {

    @Override
    public String encode(CharSequence charSequence) {
        //加密方法可以根据自己的需要修改
        return EncryptUtil.getInstance().MD5(charSequence.toString());
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        System.out.println("原始密码："+charSequence.toString()+"  数据库密码："+s);
        return encode(charSequence.toString()).equals(s);
    }
}
